﻿<navigation:Page x:Class="Corina.Lantern.Hub.Views.Device.MyDeviceView"
                 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                 xmlns:be="clr-namespace:Corina.Interactivity.Silverlight;assembly=Corina.Interactivity.Silverlight"
                 xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                 xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
                 xmlns:localViewmodel="clr-namespace:Corina.Lantern.Hub.Viewmodels"
                 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                 xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
                 xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
                 xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit"
                 Title="MyDeviceView Page"
                 FontFamily="Microsoft YaHei UI Light"
                 FontSize="14"
                 d:DesignHeight="480"
                 d:DesignWidth="960"
                 mc:Ignorable="d">
    <navigation:Page.DataContext>
        <localViewmodel:MyDeviceViewmodel />
    </navigation:Page.DataContext>
    <Grid x:Name="LayoutRoot">
        <Grid.RowDefinitions>
            <RowDefinition Height="auto" />
            <RowDefinition />
            <RowDefinition Height="auto" />
        </Grid.RowDefinitions>

        <toolkit:Expander Header="搜索">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="200" />
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="200" />
                    <ColumnDefinition />
                    <ColumnDefinition Width="Auto" />
                </Grid.ColumnDefinitions>
                <sdk:AutoCompleteBox ItemsSource="{Binding DeviceKindCollection}"
                                     MinimumPrefixLength="0"
                                     SelectedItem="{Binding SelectedDeviceKind,
                                                            Mode=TwoWay}"
                                     ValueMemberPath="Name"
                                     be:AutoCompleteBoxHelper.OtherPaths="Name,Description">
                    <sdk:AutoCompleteBox.ItemTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding Name}" />
                        </DataTemplate>
                    </sdk:AutoCompleteBox.ItemTemplate>
                    <i:Interaction.Triggers>
                        <be:AutoCompleteBoxTrigger>
                            <be:ExecuteCommandAction Command="{Binding LoadCommand}" />
                        </be:AutoCompleteBoxTrigger>
                    </i:Interaction.Triggers>
                </sdk:AutoCompleteBox>
                <TextBlock Grid.Column="1"
                           Margin="12,0,0,0"
                           VerticalAlignment="Center"
                           Text="设备序列号：" />
                <TextBox Grid.Column="2" Text="{Binding DeviceSn, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
                    <i:Interaction.Triggers>
                        <be:TextBoxEnterKeyTrigger>
                            <be:ExecuteCommandAction Command="{Binding LoadCommand}" />
                        </be:TextBoxEnterKeyTrigger>
                    </i:Interaction.Triggers>
                </TextBox>
            </Grid>
        </toolkit:Expander>

        <toolkit:BusyIndicator Grid.Row="1"
                               Margin="0,12"
                               HorizontalAlignment="Stretch"
                               VerticalAlignment="Stretch"
                               IsBusy="{Binding IsBusy}">
            <sdk:DataGrid AutoGenerateColumns="False"
                          ColumnWidth="*"
                          IsReadOnly="True"
                          ItemsSource="{Binding ItemsCollection}">
                <sdk:DataGrid.Columns>
                    <sdk:DataGridTextColumn Width="60"
                                            Binding="{Binding ItemIndex}"
                                            Header="序号" />
                    <sdk:DataGridTextColumn Width="120"
                                            Binding="{Binding DeviceSn}"
                                            Header="序列号" />
                    <sdk:DataGridTextColumn Binding="{Binding Kind}" Header="类别" />
                    <sdk:DataGridTextColumn Width="100"
                                            Binding="{Binding Transfer}"
                                            Header="数据模块" />
                    <sdk:DataGridTextColumn Width="100"
                                            Binding="{Binding ManufactureDate,
                                                              StringFormat=\{0:yyyy-MM-dd\}}"
                                            Header="生产日期" />
                    <sdk:DataGridTextColumn Width="100"
                                            Binding="{Binding SaleDate,
                                                              StringFormat=\{0:yyy-MM-dd\}}"
                                            Header="购买日期" />
                    <sdk:DataGridTextColumn Width="100"
                                            Binding="{Binding Price}"
                                            Header="售价" />
                </sdk:DataGrid.Columns>
            </sdk:DataGrid>
        </toolkit:BusyIndicator>
    </Grid>
</navigation:Page>
